<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/jsp/include/head.jsp"/>
</head>
<body>

<!-- 面包屑导航 -->
<ul class="breadcrumb">
    <li><strong>当前位置： </strong>基础设置</li>
    <li class="active">请假事由</li>
</ul>



<button id="toolbar" style="margin-left: 5px" type="button" class="btn btn-default"><span
        class="glyphicon glyphicon-plus-sign"></span>&nbsp;添加&nbsp;
</button>


<table id="table_data"></table>


<div class="modal fade" id="modal_ajax">
    <div class="modal-dialog ">
        <div class="modal-content ">
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>

<script>
        var $table = $('#table_data');
        $table.bootstrapTable({
            url: '<%=request.getContextPath()%>/dictionary/leaveReason/select',
            striped: true,
            cache: false,
            showRefresh: true,
            searchOnEnterKey: false,
            search: true,
            toolbar: "#toolbar",
            toolbarAlign: 'right',
            pagination: false,
            queryParams: function (params) {
                return params
            },
            columns: [
                {
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                }, {
                    field: 'name',
                    title: '名称',
                    switchable:false
                }, {
                    title: '操作',
                    events: 'Events',
                    formatter: function (value, row, index) {

                        return [
                            '<div class="btn-group btn-group-xs" role="group" >'

                            +'<button type="button" class="btn btn-xs btn-default update_data">' +
                            '<span class="glyphicon glyphicon-edit  "></span> 修改' +
                            '</button>'
                            +'<button type="button" class="btn btn-xs btn-default delete_data">' +
                            '<span class="glyphicon glyphicon-remove"></span> 删除' +
                            '</button>'
                            +'</div>'
                        ].join('');
                    }
                }
            ]
        });
        window.Events = {
            'click .update_data': function (e, value, row, index) {
                $('#modal_ajax').modal({
                    backdrop: 'static',
                    keyboard: false,
                    show: true,
                    remote: 'dictionary/leaveReason/editDlg?id='+row.id
                });
            },

            'click .delete_data': function (e, value, row, index) {
                $.sysPlugin.superAjax({
                    data: {id:row.id},
                    url: 'dictionary/leaveReason/delete',
                    operateType: 'delete',
                    showSuccessAlert: true,
                    showWarnAlert: true,
                    successCall: function (data) {
                        $.sysPlugin.successCallBack(data, {
                            table: $("#table_data")
                        })
                    }
                })
            }
        };
        $("#toolbar").click(function () {
            $('#modal_ajax').modal({
                backdrop: 'static',
                keyboard: false,
                show: true,
                remote: 'dictionary/leaveReason/editDlg'
            });
        });

        $.sysPlugin.clearModalRemoveData("modal_ajax");
</script>


</body>
</html>